﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Human
{
    class Program
    {
        static void Main(string[] args)
        {

            Man Adam = new Man(null, null, Human.GetRandomName());
            Woman Eve = new Woman(null, null, Human.GetRandomName());
            Man Kain = new Man(Adam, Eve, Human.GetRandomName());
            Woman Avan = new Woman(Adam, Eve, Human.GetRandomName());
           

            Console.WriteLine(Adam.MyInfo());
            Console.WriteLine(Eve.MyInfo());
            
            Kain.AddCar("Chevrolet");
           
            Console.WriteLine(Kain.MyInfo());
            Console.WriteLine(Avan.MyInfo());
            Console.ReadLine();


        }
    }
    public class Human
    {

        public static List<string> name = new List<string>();

        Human f;
        Human m;
        string name2;
        static string name1;
        List<Human> children = new List<Human>();
        


        public Human(Human father, Human mother, string Name)
        {
            f = father;
            m = mother;
            name2 = Name;
            if(f != null)
            f.children.Add(this); 
            if (m != null)
            m.children.Add(this);

        }
        public virtual string MyInfo()
        {
            
            string result = " Меня зовут " + name2;

            if (f == null)
            {
                result += ". Я не знаю отца.";
            }
            else
            {
                result += ". Мой отец: " + f.name2;
            }
            if (m == null)
            {
                result += " Я не знаю мать.";
            }
            else
            {
                result += ". Моя мать: " + m.name2;
            }
            if (children.Count != 0)
            {
                result += " Мои дети: ";
                foreach (Human child in children)
                {
                    result +=" " + child.name2;
                }
            }
            else
            {
                result += ". Детей нет";
            }
    return result;
        }
        
            /*if (Woman.food != null && Woman.food.Count > 1 && Woman.food[1] != null)
            {
                foreach (string Food in Woman.food)
                {
                    result += ". Любимая еда: " + Food;
                }
            }*/

            


        public static string[] names = new string[5] { "Вася", "Петя", "Аня", "Женя", "Даша" };
        static Random r = new Random();
        static public  string GetRandomName()
        {
            int i = r.Next(names.Length);
            name1 = names[i];
            return name1;

        }

    }
    class Man : Human
    {

        private List<string> cars = new List<string>();
        public void AddCar (string newCar){
            cars.Add(newCar);
        }
        public Man(Human father, Human mother, string name1)
            : base(father, mother, name1)
        {
/*cars.Add("Renault");
        cars.Add("Chevrolet");
        cars.Add("Ford");
        cars.Add("Toyota");*/
        }
        public override string  MyInfo()
        {   string result = "Привет, я мужчина. " + base.MyInfo();
            if (cars != null && cars.Count > 0){
                result += ". Любимые марки машин: ";
                foreach (string car in cars)
                
                    {
                        result +=" "+   car;
                    }
                }
            return result;
        }


    }
    class Woman : Human
    {

        /*public static List<string> food = new List<string>();
        food.Add("Пончики");
        food.Add("Конфеты");*/


        public Woman(Human father, Human mother, string name1)
            : base(father, mother, name1)
        {

        }
        public override string MyInfo()
        {
            return "Привет, я женщина. " + base.MyInfo();
        }


    }



}

